//
//  HLHomeCellBottomView.swift
//  weibo-snh
//
//  Created by 黄力 on 15/12/20.
//  Copyright © 2015年 HLTest. All rights reserved.
//

import UIKit
import SnapKit

class HLHomeCellBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        //设置界面
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //设置界面
    private func setupUI() {
        
        //添加子控件
        addSubview(retweetBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        //创建分割线
        let lineOne = createSparateLine()
        let lineTwo = createSparateLine()
        addSubview(lineOne)
        addSubview(lineTwo)
        //设置约束
        //转发
        retweetBtn.snp_makeConstraints { (make) -> Void in
            make.top.left.height.equalTo(self)
        }
        //评论
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetBtn.snp_right)
            make.top.height.width.equalTo(retweetBtn)
        }
        //赞
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.right.equalTo(self)
            make.top.height.width.equalTo(retweetBtn)
        }
        //分割线
        lineOne.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(self)
            make.centerX.equalTo(retweetBtn.snp_right)
            make.width.equalTo(1)
            make.height.equalTo(self).multipliedBy(0.4)
        }
        //分割线
        lineTwo.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(self)
            make.centerX.equalTo(commentBtn.snp_right)
            make.width.equalTo(1)
            make.height.equalTo(self).multipliedBy(0.4)
        }
    }
    
    //分割线
    private func createSparateLine() -> UIView {
        let sView = UIView()
        sView.backgroundColor = UIColor.blackColor()
        return sView
    }
    
    //MARK: 懒加载子控件
    //转发
    private lazy var retweetBtn: UIButton = UIButton(title: "转发", titleColor: UIColor.lightGrayColor(), titleFont: 14, backImageName: "", imageName: "timeline_icon_retweet")
    //评论
    private lazy var commentBtn: UIButton = UIButton(title: "评论", titleColor: UIColor.lightGrayColor(), titleFont: 14, backImageName: "", imageName: "timeline_icon_comment")
    //赞
    private lazy var likeBtn: UIButton = UIButton(title: "赞", titleColor: UIColor.lightGrayColor(), titleFont: 14, backImageName: "", imageName: "timeline_icon_unlike")
}
